<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>update Emp</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link rel="stylesheet" type="text/css"
			href="css/style.css" />
			<script type="text/javascript" src="js/vue.js"></script>
			<script type="text/javascript" src="./js/axios.min.js"></script>
			<script type="text/javascript" src="js/const.js"></script>
	</head>

	<body>
		<div id="wrap">
			<div id="top_content">
					<div id="header">
						<div id="rightheader">
							<p>
								2009/11/20
								<br />
							</p>
						</div>
						<div id="topheader">
							<h1 id="title">
								<a href="emplist.html">Main</a>
							</h1>
						</div>
						<div id="navigation">
						</div>
					</div>
				<div id="content">
					<p id="whereami">
					</p>
					<h1>
						update Emp info:
					</h1>
				
						<table cellpadding="0" cellspacing="0" border="0"
							class="form_table">
							<tr>
								<td valign="middle" align="right">
									id:
								</td>
								<td valign="middle" align="left" id="userid">
									?
								</td>
							</tr>
							<tr>
								<td valign="middle" align="right">
									name:
								</td>
								<td valign="middle" align="left">
									<input type="text" class="inputgri" v-model="username"/>
								</td>
							</tr>
							<tr>
								<td valign="middle" align="right">
									salary:
								</td>
								<td valign="middle" align="left">
									<input class="inputgri" v-model="usersalary"/>
								</td>
							</tr>
							<tr>
								<td valign="middle" align="right">
									age:
								</td>
								<td valign="middle" align="left">
									<input type="text" class="inputgri" v-model="userage"/>
								</td>
							</tr>
						</table>
						<p>
							<input type="button" class="button" value="Confirm" v-on:click="update()" />
						</p>
				
				</div>
			</div>
			<div id="footer">
				<div id="footer_bg">
					ABC@126.com
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript">
		var config={
			el:"#wrap",
			data:{
				userId:"",
				usersalary:"",
				username:null,
				userage:""
			},
			methods:{
				update:function(){
					debugger;
					var url=serverUrl+"/update?userId="+array[1]
					+"&name="+this.username+
					"&age="+this.userage+
					"&salary="+this.usersalary;
					axios.get(url)
					.then(function(res){
						debugger;
						console.log(res);
						window.alert("修改成功");
						location.href="emplist.html";
					})
					.catch(function(e){
						console.log(e);
					});
				},
				select:function(){
					debugger;
					var url=serverUrl+"/findAll";
					axios.get(url)
					.then(function(res){
					debugger;
					var user=res.data;
					this.vue.username=user.name;
					this.vue.userage=user.age;
					this.vue.usersalary=user.salary;
					})
					.catch(function(e){
						console.log(e);
					})
				}
			},
			mounted:function(){
				this.select();
			}
		}
		var search = location.search;
		search = search.substr(1);
		var array = search.split("=");
		document.getElementById("userid").innerText=array[1];
		var vue=new Vue(config);
	</script>
</html>
